function normalizeMP(val) if val > 100 then val = 100 elseif val < 1 then val = 1 end return val end function read_if_exist(section, value, default) if ini_sys:section_exist(section) and ini_sys:line_exist(section,value) then return ini_sys:r_float_ex(section,value) else return default end end function read_float(wpn_section, upgr_sections, param) local res = 0 if (param == "hit_power") then local t = parse_names(ini_sys:r_string_ex(wpn_section,param) or "") res = tonumber(t[1]) or 0 else res = ini_sys:r_float_ex(wpn_section, param) or param == "control_inertion_factor" and 1 or 0 end if upgr_sections == nil or upgr_sections == "" then return res end for k, sect in pairs(parse_names(upgr_sections)) do if param == "hit_power" then local r = parse_names(ini_sys:r_string_ex(sect,param) or "") r = tonumber(r[1]) or 0 if res < r then res = r end else res = res + (ini_sys:r_float_ex(sect,param) or 0) end end return res end function GetRPM(wpn_section, upgr_sections) --' скорострельность local rpm = read_float(wpn_section, upgr_sections, "rpm") return normalize_100(rpm, 0, 1000) end function GetDamage(wpn_section, upgr_sections) --' повреждение local hit_power = read_float(wpn_section, upgr_sections, "hit_power") if ini_sys:line_exist(wpn_section, "ammo_class") then local ammo_list = ini_sys:r_string(wpn_section, "ammo_class") if (ammo_list) then local pos = string.find(ammo_list, ",", 1) local ammo = (pos ~= nil) and string.sub(ammo_list, 1, pos-1) or ammo_list local k_hit = ini_sys:r_float_ex(ammo, "k_hit") or 1 hit_power = (hit_power ~= 0) and (k_hit*hit_power) or k_hit end end return normalize_100(hit_power, 0, 1.5) end function GetDamageMP(wpn_section, upgr_sections) -- ??? (повреждениеMP) local hit_power = read_float(wpn_section, upgr_sections, "hit_power") hit_power = hit_power * 100 -- if val < 1.05 then -- val = val*100-30 -- else -- val = 75 + math.pow(val/4,2)*25 -- end return normalizeMP(hit_power) end function GetHandling(wpn_section, upgr_sections) --' удобность local PDM_disp_base = read_float(wpn_section, upgr_sections, "PDM_disp_base") local control_inertion_factor = read_float(wpn_section, upgr_sections, "control_inertion_factor") return (normalize_100(PDM_disp_base, 2.1, 0) + normalize_100(control_inertion_factor, 3, 1))/2 end function GetAccuracy(wpn_section, upgr_sections) --' точность local fire_dispersion_base = read_float(wpn_section, upgr_sections, "fire_dispersion_base") return normalize_100(fire_dispersion_base, 1.5, 0) end